<template>
	<view>
		<view v-if="isValid" style="min-height: 100vh;display: flex;justify-content: center;align-items: center;">
			暂未开放
		</view>
		<view v-else>
			<view class="item" @click="openPluginPage('plugin://keepPlugin/lbk_ljj')">
				龙宝卡立减金插件</view>
			<view class="item"
				@click="productHalfScreen('pages/lbk_tcq/lbk_tcq?a=123aaa&param=lc456&backMiniParam=test')">
				半屏龙宝省心卡停车券</view>
			<view class="item"
				@click="productHalfScreen('pages/lbk_cdq/lbk_cdq?a=123aaa&param=lc456&backMiniParam=test')">
				半屏龙宝省心卡充电券</view>
			<view class="item"
				@click="productHalfScreen('pages/lbk_ljj/lbk_ljj?a=123aaa&param=lc456&backMiniParam=test')">
				半屏龙宝省心卡立减金</view>
		</view>
	</view>
</template>

<script>
	import {
		shenhe
	} from "@/api/index.js"
	const keepPlugin = requirePlugin("keepPlugin");

	export default {
		data() {
			return {
				// 省心云链停车 2021004115620105
				// 省心云链充电 2021004135681441
				// 省心云生活 2021004123656452

				appid: '2021004115620105',
				isValid: false,
			}
		},
		onLoad() {
			shenhe({
				pid: 1,
				ver: 15
			}).then((res) => {
				console.log(res)
				this.isValid = res.data.is > 0
			})

			keepPlugin.setA("123aaa");
			keepPlugin.setParam("123456");
			keepPlugin.setAppid("2021004123656452");
			keepPlugin.setOpenid('openid');
		},
		onShow(option) {
			console.log('option', option)
		},
		methods: {

			/**
			 * 打开插件页面
			 * @param {Object} pagePath
			 */
			openPluginPage(pagePath) {
				uni.navigateTo({
					url: pagePath
				})
			},

			devProduct(pagePath) {
				uni.navigateToMiniProgram({
					appId: this.appid,
					path: pagePath,
					envVersion: 'trial',
					extraData: {},
					success(res) {
						// 打开成功
					}
				})
			},
			product(pagePath) {
				uni.navigateToMiniProgram({
					appId: this.appid,
					path: pagePath,
					extraData: {},
					success(res) {
						// 打开成功
					}
				})
			},
			devProductHalfScreen(pagePath) {
				uni.openEmbeddedMiniProgram({
					appId: this.appid,
					path: pagePath,
					envVersion: "trial",
					extraData: {

					},
					success(res) {
						// 打开成功
					}
				})
			},
			productHalfScreen(pagePath) {
				uni.openEmbeddedMiniProgram({
					appId: this.appid,
					path: pagePath,
					extraData: {

					},
					success(res) {
						// 打开成功
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.item {
		border: solid 1rpx black;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
	}
</style>